/**
* Created by yyr on 2018/1/10
*已设立基金》选项卡基本信息
*/
<template>
    <div>
        <div class="ca-box-border-top-none ca-p-22">
            <el-row class="ca-m-b-25">
                <el-col :span="12" class="ca-title clearfix">
                    <h3>基本信息</h3>
                </el-col>
                <el-col :span='12' class="ca-align-right" v-if="!isAdd">
                    <div>
                        <el-button type="primary" @click="saveFundBasic()" size="medium">保存</el-button>
                        <el-button  @click="cancel()" size="medium">取消</el-button>
                    </div>
                </el-col>
            </el-row>
            <el-form label-width="200px">
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="管理类型">
                            <el-select v-model="fundEst.manType" placeholder="请选择" style="width: 100%">
                                <el-option
                                    v-for="item in initView.fundManType"
                                    :label="item.name"
                                    :key="item.id"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="管理形式">
                            <el-select v-model="fundEst.fundForm" placeholder="请选择" style="width: 100%">
                                <el-option
                                    v-for="item in initView.fundForm"
                                    :label="item.name"
                                    :key="item.id"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="基金委派代表">
                            <el-input v-model="fundEst.fundDelegate" :maxlength="100"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="基金委托管理人">
                            <el-input placeholder="请输入内容" v-model="fundEst.custodian"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="23">
                        <csRegion title="注册地点"
                                  :address="address"
                                  :labelWidth=labelWidth
                                  ref="regist">
                        </csRegion>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="是否在中基协备案">
                            <el-select v-model="fundEst.icc" placeholder="请选择" style="width: 100%">
                                <el-option
                                    v-for="item in initView.whether"
                                    :label="item.name"
                                    :key="item.id"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="中基协备案号">
                            <el-input placeholder="请输入内容" v-model="fundEst.iccNumber" :maxlength="100"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="是否在金融办备案">
                            <el-select v-model="fundEst.finance" placeholder="请选择" style="width: 100%">
                                <el-option
                                    v-for="item in initView.whether"
                                    :label="item.name"
                                    :key="item.id"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item label="金融办备案号">
                            <el-input placeholder="请输入内容" v-model="fundEst.financeNumber" :maxlength="100"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="投资决策委员会">
                            <el-row>
                                <el-select v-model="committeeName"
                                           @change="changeCommitteeName"
                                           filterable placeholder="请选择" style="width:100%;">
                                    <el-option
                                        v-for="item in userOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-row>
                        </el-form-item>
                    </el-col>
                    <el-col :span="11" class="ca-m-l-10">
                        <el-tag
                            v-for="item in committeeList"
                            :key="item.id"
                            :closable="true"
                            :close-transition="false"
                            @close="closeCommitteeItem(item)"
                            class="ca-m-r-10 ca-m-t-8">
                            {{item.committeeName}}
                        </el-tag>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                        <el-form-item label="收益分配">
                            <el-input  type="textarea" :maxlength="4000" placeholder="请输入内容" v-model="fundEst.distribution"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                        <el-form-item label="投资地域">
                            <el-input  type="textarea"
                                       :maxlength="4000"
                                       placeholder="请输入内容"
                                       v-model="fundEst.investmentRegion"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                        <el-form-item label="投资方向">
                            <el-input  type="textarea"  :maxlength="4000" placeholder="请输入内容" v-model="fundEst.investmentDirection"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                        <el-form-item label="退出方式">
                            <el-input  type="textarea"  :maxlength="4000" placeholder="请输入内容" v-model="fundEst.exitMode"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                        <el-form-item label="投资限制">
                            <el-input  type="textarea"  :maxlength="4000" placeholder="请输入内容" v-model="fundEst.restrictions"></el-input>
                        </el-form-item>
                        <el-form-item label="信息披露">
                            <el-input  type="textarea"  :maxlength="4000" placeholder="请输入内容" v-model="fundEst.disclosure"></el-input>
                        </el-form-item>
                        <el-form-item label="其他">
                            <el-input type="textarea" :maxlength="4000" placeholder="请输入内容" v-model="fundEst.other"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
//    import {api} from '../api';
//    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp'
    export default {
        data() {
            return {
                labelWidth: '198px',
                initView: {
                    fundType: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.fundType],//基金类型
                    industry: this.$store.state.user.dictionaryMap.industry, //投资方向
                    fundState: this.$store.state.user.dictionaryMap.foundation,// 设立状态
                    fundManType: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.fundManType],//管理类型
                    fundForm: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.fundForm],//管理形式
                    userEntityList: this.$store.state.user.department.userEntityList,//用户
                    whether: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.whether],//是否
                },
                itemId: this.$route.params.fundId,
                userOptions: [],
                partnerName: '',//执行事务合伙人name
                committeeName: '',//委员会的Name
                address: {
                    province: null,
                    city: null,
                    district: null,
                    businessType: 1,
                    registrationDetailed: ''
                },
            }
        },
        props: {
            isAdd: {
                type: Boolean,
                default() {
                    return false;
                }
            },
            fundEst: {
                type: Object,
                default() {
                    return {};
                }
            },
            committeeList: {
                type: Array,
                default() {
                    return [];
                }
            },
        },
        watch: {
            address: {
                handler(val) {
                    this.$emit('changeRegion', val)
                },
                deep: true
            },
        },
        created() {
        },
        mounted() {
            this.userOptions = this.initView.userEntityList.map(item => {
                return { value: item.id, label: item.userName };
            });
            if (this.fundEst.regionList && this.fundEst.regionList.length > 0) {
                this.address = {
                    province: this.fundEst.regionList[0].province,
                    city: this.fundEst.regionList[0].city,
                    district: this.fundEst.regionList[0].district,
                    businessType: 1,
                    registrationDetailed: this.fundEst.regionList[0].registrationDetailed
                };
                this.$refs.regist.inview(this.address)
            }
        },
        methods: {
            saveFundBasic() {
                this.$emit('saveFundBasic',this.committeeList,this.fundEst)
            },
            cancel() {
                this.$emit('isEdit',false)
            },
            //关闭投资决策委员会
            closeCommitteeItem(tag) {
                this.$emit('closeCommitteeItem', tag)
            },
            //执行事务合伙人change
//            changePartnerName(val) {
//                let name = '';
//                this.initView.userEntityList.map( item=> {
//                    if (item.id === val) {
//                        name = item.userName
//                    }
//                })
//                this.fundEst.partnerName = name;
//                this.fundEst.partnerId = val;
//            },
            //投资决策委员会change
            changeCommitteeName(val) {
                this.$emit('changeCommitteeName',val)
            }
        },
        components: {
            'csRegion': require('__components/region/index'), // 注册地点组件
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>

</style>
